<?php
  /**
   * This class controls the routing for the framework
   *
   * @author Macdonald Terrence Robinson
   * @package Core
   *
   */
  final class Router
  {
    public static $controller = '';
    public static $function = '';
    public static $params = array();
    
    public static function forceToProtocol($protocol)
    {
      if(Config::$protocol != $protocol)
      {
        $newUrl = $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        header('Location: '.$newUrl);
        exit;
      }
    }

    public static function init()
    {      
      self::$controller = URI::getSegment(0);
      self::$function = URI::getSegment(1);

      if(self::$controller == '')
        self::$controller = Config::$defaultController;

      if(self::$function == '')
        self::$function = Config::$defaultFunction;
        

      self::$function = strtolower(self::$function);
      self::$controller = strtolower(self::$controller);
    }
    
  }
?>
